/**
 * copyright (c) 2017-2023 厦门风领科技有限公司
 * https://www.fengling.cn/
 * 
 * QQ小游戏适配
 * zengbinsi
 * 2020-08-15 15:32:45
 * 2023-10-23 15:32:28
 */

window.gg = window.gg || {};

if (gg.isMiniGameQQ) {
    console.log('[TS-API] ===>>>', '适配QQ小游戏平台');
    gg.channel = cc.sys.os === cc.sys.OS_IOS ? gg.EChannelType.MINI_GAME_QQ_IOS : gg.EChannelType.MINI_GAME_QQ_AND;

    gg.getStorageSync = (key, defaultVal) => {
        let res = qq.getStorageSync(key);
        return gg.isEmptyString(res) ? defaultVal : res;
    };

    /**九宫格*/
    gg._createGamePortalAdQQ = gg.createAppBox;
    gg.createGamePortalAd = (data) => {
        data.adUnitId = data.adUnitId;
        if (!data.adUnitId) return gg.error('格子广告id为空');
        return gg._createGamePortalAdQQ(data);
    };

    gg.showToast = (data) => {
        qq.showToast({
            title: data.title || '',
            icon: data.icon || '',
            image: data.image || '',
            duration: (data.duration * 1000) || 1500,
            mask: data.mask || false,
            success: data.success || null,
            fail: data.fail || null,
            complete: data.complete || null,
        });
    };
}

